#include <stdio.h>
#include <src/algo.h>
#include <src/iterator.h>
#include <src/Vector.h>

int main(int argc, char *argv[]) {
	Vector vector;
	vectorConstruct(&vector);

	printf("[INF] (%s, %d) %s\n", __FILE__, __LINE__, "========");

	printf("[INF] (%s, %d) %s\n", __FILE__, __LINE__, "Insert");
	for (int i = 0; i < 10; ++i) {
		vectorInsert(&vector, vectorBegin(&vector), i);
	}
	for (int i = 10; i < 20; ++i) {
		vectorInsert(&vector, vectorBegin(&vector), i);
	}
	vectorInsertN(&vector, advance(Vector, vectorBegin(&vector), 10), 10, 100);
	forEach (Vector, iterator, vector) {
		printf("[INF] (%s, %d) %d\n", __FILE__, __LINE__, *vectorIteratorIndirect(&iterator));
	}

	printf("[INF] (%s, %d) %s\n", __FILE__, __LINE__, "Sort");
	vectorSort(vectorBegin(&vector), vectorEnd(&vector));
	forEach (Vector, iterator, vector) {
		printf("[INF] (%s, %d) %d\n", __FILE__, __LINE__, *vectorIteratorIndirect(&iterator));
	}

	printf("[INF] (%s, %d) %s\n", __FILE__, __LINE__, "LowerBound");
	printf("[INF] (%s, %d) %lu\n", __FILE__, __LINE__, distance(Vector, vectorBegin(&vector), binaryLowerBound(Vector, vectorBegin(&vector), vectorEnd(&vector), 0)));
	printf("[INF] (%s, %d) %lu\n", __FILE__, __LINE__, distance(Vector, vectorBegin(&vector), binaryLowerBound(Vector, vectorBegin(&vector), vectorEnd(&vector), 10)));
	printf("[INF] (%s, %d) %lu\n", __FILE__, __LINE__, distance(Vector, vectorBegin(&vector), binaryLowerBound(Vector, vectorBegin(&vector), vectorEnd(&vector), 100)));
	printf("[INF] (%s, %d) %lu\n", __FILE__, __LINE__, distance(Vector, vectorBegin(&vector), binaryLowerBound(Vector, vectorBegin(&vector), vectorEnd(&vector), 1000)));

	printf("[INF] (%s, %d) %s\n", __FILE__, __LINE__, "UpperBound");
	printf("[INF] (%s, %d) %lu\n", __FILE__, __LINE__, distance(Vector, vectorBegin(&vector), binaryUpperBound(Vector, vectorBegin(&vector), vectorEnd(&vector), 0)));
	printf("[INF] (%s, %d) %lu\n", __FILE__, __LINE__, distance(Vector, vectorBegin(&vector), binaryUpperBound(Vector, vectorBegin(&vector), vectorEnd(&vector), 10)));
	printf("[INF] (%s, %d) %lu\n", __FILE__, __LINE__, distance(Vector, vectorBegin(&vector), binaryUpperBound(Vector, vectorBegin(&vector), vectorEnd(&vector), 100)));
	printf("[INF] (%s, %d) %lu\n", __FILE__, __LINE__, distance(Vector, vectorBegin(&vector), binaryUpperBound(Vector, vectorBegin(&vector), vectorEnd(&vector), 1000)));

	printf("[INF] (%s, %d) %s\n", __FILE__, __LINE__, "Erase");
	vectorEraseN(&vector, vectorBegin(&vector), 10);
	vectorEraseIn(&vector, advance(Vector, vectorBegin(&vector), 10), advance(Vector, vectorBegin(&vector), 20));
	forEach (Vector, iterator, vector) {
		printf("[INF] (%s, %d) %d\n", __FILE__, __LINE__, *vectorIteratorIndirect(&iterator));
	}

	printf("[INF] (%s, %d) %s\n", __FILE__, __LINE__, "========");

	vectorDestruct(&vector);
	return 0;
}
